from fastapi import APIRouter, HTTPException
from httpx import AsyncClient
import config_read

key = config_read.config_read('gaode_api')
url = '?'
place_api=APIRouter()

@place_api.get('/get')
async def get_place(addr: str):
    async with AsyncClient() as ac:
        try:
            response = await ac.get(f'https://restapi.amap.com/v3/geocode/geo?address={addr}&key={key}')
            return response.json()
        except HTTPException:
            raise HTTPException(500, 'API失败')
